<?php
header("Pragma: ");
header('Cache-control: ');
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Content-type: application/vnd.ms-word");
header("Content-disposition: attachment; filename='ResumenesPresupuestarios.xml'");
?> 
<html>
    <head>
        <title>EXPORTANDO EXCEL</title>
        <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    </head>
<body>
<div align="center"><h1>RESUMENES PRESUPUESTARIOS</h1></div><br>

<div align="center"><br>

    <br>
    <div id="cajapresupuestosindex" align="center">
        <table border="1" width="200" cellspacing="10" cellpadding="10" id="Exportar_a_Excel" class="table" align="center" name="campo">
            <tr style="background-color: #328a26;" align="center">
                <td colspan="5">RESUMEN PRESUPUESTARIO FONDO <?php echo $fdefecto->getSiglasInst() ?></td>
            </tr>
            <tr style="background-color: #328a26;" align="center">
                <td>&nbsp;Recurso&nbsp;</td>
                <?php for ($i = $añoinicial; $i <= $añofinal; $i++) { ?>
                    <td>&nbsp;<?php echo $i ?>&nbsp;</td>        
                <?php } ?>       
                <td>&nbsp;Total&nbsp;</td>
            </tr>
            <?php foreach ($techospresupuestarios as $t):
                $total1 = 0 ?>  
                <tr align="center">
                    <td><?php echo $t->getNombre() ?></td>
                    <?php
                    for ($i = $añoinicial; $i <= $añofinal; $i++) {
                        $idauxtp = $t->getIdTp();
                        $sumavalor1 = 0;
                        foreach ($objetivos as $ob):
                            $idauxob = $ob->getIdOb();
                            foreach ($actividades as $ac):
                                if ($ac->getIdOb() == $idauxob) {
                                    $idauxac = $ac->getIdAc();
                                    foreach ($descripciones as $de):
                                        if ($de->getIdAc() == $idauxac && $de->getIdTp() == $idauxtp) {
                                            $idauxde = $de->getIdDe();
                                            foreach ($valores as $va):
                                                if ($va->getIdDe() == $idauxde && $va->getIdFo() == $fdefecto->getIdFo() && $va->getAnio() == $i) {
                                                    $sumavalor1 = $sumavalor1 + $va->getVal();
                                                }
                                            endforeach;
                                        }
                                    endforeach;
                                }
                            endforeach;
                        endforeach;
                        ?>                
                        <td><?php echo $sumavalor1 ?></td>        
                        <?php $total1 = $total1 + $sumavalor1; ?>


                    <?php } ?>   
                    <td><?php echo $total1 ?></td>        
                </tr>
            <?php endforeach; ?>

            <tr style="background-color: #328a26;" align="center">
                <td align="center">TOTAL:</td>
                <?php
                $totalhorizontal1 = 0;
                for ($i = $añoinicial; $i <= $añofinal; $i++) {
                    $sumavalorvertical1 = 0;
                    foreach ($techospresupuestarios as $tp):
                        $idauxtp = $tp->getIdTp();

                        foreach ($objetivos as $ob):
                            $idauxob = $ob->getIdOb();
                            foreach ($actividades as $ac):
                                if ($ac->getIdOb() == $idauxob) {
                                    $idauxac = $ac->getIdAc();
                                    foreach ($descripciones as $de):
                                        if ($de->getIdAc() == $idauxac && $de->getIdTp() == $idauxtp) {
                                            $idauxde = $de->getIdDe();
                                            foreach ($valores as $va):
                                                if ($va->getIdDe() == $idauxde && $va->getIdFo() == $fdefecto->getIdFo() && $va->getAnio() == $i) {
                                                    $sumavalorvertical1 = $sumavalorvertical1 + $va->getVal();
                                                }
                                            endforeach;
                                        }
                                    endforeach;
                                }
                            endforeach;
                        endforeach;
                    endforeach;
                    ?>
                    <td><?php echo $sumavalorvertical1 ?></td> 
                    <?php $totalhorizontal1 = $totalhorizontal1 + $sumavalorvertical1 ?>

                <?php } ?> 
                <td><?php echo $totalhorizontal1 ?></td>  
            </tr>
        </table><br>
    </div>
    <br><br>
    

    <br>
</div><br>
</body>
</html> 
</div>

<br>
</div><br>
<a href="<?php echo url_for('Reportes/ExportarResumenFondoPDF')?>"><button id="botonExcel" class="button button-green" type="submit"><span><div  align="center" class="spritesexportre" id="exportre_jpg" align="center"></div>Exportar A PDF</span></button></a>&nbsp;
<a href="<?php echo url_for('Reportes/ExportarResumenFondoExcel')?>"><button class="button button-green"><span><div  align="center" class="spritesexportre" id="exportre_jpg"align="center"></div>EXPORTAR A EXCEL</span></button></a>&nbsp;
<a href="<?php echo url_for('Reportes/index')?>"><button class="button2 button-green2"><span><div align="center"  class="spritesatras" id="atras_jpg" align="center"></div>Regresar a Menu_Reportes</span></button></a>&nbsp;



